package net.yunzhanyi.client.manager;

import net.yunzhanyi.client.domain.dto.ClientLoginUser;
import net.yunzhanyi.common.web.util.SpringUtils;
import net.yunzhanyi.generic.domain.model.ClientLoginLog;
import net.yunzhanyi.generic.mapper.ClientLoginLogMapper;

import java.util.TimerTask;

/**
 * @author bestct
 * @date 2022/7/23
 * @type 类
 */
public class AsyncFactory {

    public static TimerTask recordLoginLog(ClientLoginUser loginUser) {
        return new TimerTask() {
            @Override
            public void run() {
                ClientLoginLog clientLoginLog = new ClientLoginLog();
                clientLoginLog.setLoginTime(System.currentTimeMillis());
                clientLoginLog.setAid(loginUser.getAid());
                clientLoginLog.setIp(loginUser.getIpaddr());
                clientLoginLog.setLoginDevice(loginUser.getBrowser() + "  " + loginUser.getOs());
                clientLoginLog.setIpLocation(loginUser.getLoginLocation());
                SpringUtils.getBean(ClientLoginLogMapper.class).insertSelective(clientLoginLog);
            }
        };
    }
}
